package com.wangan.wanganpush.stomp.controller;

import com.wangan.wanganpush.props.MyProps;
import com.wangan.wanganpush.services.GetXmlSendZipUtil;
import com.wangan.wanganpush.stomp.RelinkMap.LinkMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping("/stomp")
public class PageTransferController {

	@Autowired

	UserRegController userRegController;

	@Autowired
	UserLoginController userLoginController;

	@Autowired
    VehicleController vehicleController;

	@Autowired
	TrajectoryController trajectoryController;

	@Autowired
	OrderInfoController orderInfoController;

	@Autowired
	GetXmlSendZipUtil getXmlSendZipUtil;

	@Resource
	MyProps myProps;

	@RequestMapping(value="/addLink")
	public String toIndex(){
		System.out.println("开始订阅队列信息！");
		userRegController.getUserRegInfo();

		userLoginController.getUserLoginInfo();

		vehicleController.getVehicleInfo();

		trajectoryController.getTrajectoryInfo();

		orderInfoController.getOrderInfo();

		return "index";
		
	}
	
	
	@RequestMapping(value="/stopStompLink")
	public String stompLink(){
		System.out.println("开始stop连接！");
		try {
			LinkMap.removeAllStompLink();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}


	@RequestMapping(value="/startSendData")
	public String startSendData(){
		System.out.println("发送数据！");
		try {
			//   /ydx/push-wa/docs/
			List<String> fileNameList = getXmlSendZipUtil.getFileNameList(myProps.getJarPath());
			for(int i = 0; i < fileNameList.size() ; i++){
				String[] split = fileNameList.get(i).split(".zip");
				getXmlSendZipUtil.sendZip(null,null,null,split[0],fileNameList.get(i));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}

    //车辆数据的过滤复制
    public Boolean copyVehicleInfo(){





       return null;
	}

	
}
